//
//  ListViewController.swift
//  fruit-helper-swift
//
//  Created by 赵隆杰 on 2022/6/27.
//

import UIKit

class ListViewController: BaseViewController {
    
    var _typeId: String!
    var _storeTableView: ListTableView!

    override func viewDidLoad() {
        super.viewDidLoad()

        let storeTableView = ListTableView.init()
        storeTableView.tableHeaderReloadBlock = { () -> Void in
            self.refreshData()
        }
        view.addSubview(storeTableView)
        storeTableView.snp.makeConstraints { make in
            make.edges.equalTo(view)
        }
        _storeTableView = storeTableView
        
    }
    override func viewWillAppear(_ animated: Bool) {
        super.viewWillAppear(animated)
        refreshData()
    }

    init(typeId: String) {
        super.init()
        
        _typeId = typeId
    }
    
    required init?(coder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
    func refreshData() {
        var dataArray: [BookModel]
        if Int(_typeId!) == 0 {
            dataArray = LocalData().getAllAddBooks()
        } else {
            dataArray = LocalData().getAllFinishBooks()
        }
        _storeTableView.modelList_ = dataArray
        
    }
    
    
}
